﻿<Page
    x:Name="PageRoot"
    x:Class="PlayToExample.PlayToReceiverPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">Play To Receiver</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="1" Margin="120, 0, 40, 40">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="160"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" Margin="0,0,20,0">
                <Button Content="Start Receiver" HorizontalAlignment="Stretch" Click="HandleStartReceiverClicked"/>
                <Button Content="Stop Receiver" HorizontalAlignment="Stretch" Click="HandleStopReceiverClicked"/>
            </StackPanel>
            <Grid Grid.Column="1" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="Black" BorderThickness="1">
                    <Grid>
                        <Image x:Name="ImagePlayer" HorizontalAlignment="Center" ImageFailed="HandleImagePlayerImageFailed"/>
                        <MediaElement x:Name="VideoPlayer" 
                                      MediaOpened = "HandleVideoPlayerMediaOpened"
                                      CurrentStateChanged = "HandleVideoPlayerCurrentStateChanged"
                                      RateChanged = "HandleVideoPlayerRateChanged"
                                      SeekCompleted = "HandleVideoPlayerSeekCompleted"
                                      MediaEnded = "HandleVideoPlayerMediaEnded"
                                      VolumeChanged = "HandleVideoPlayerVolumeChanged"
                                      MediaFailed = "HandleVideoPlayerMediaFailed"
                                      AreTransportControlsEnabled="True"
                                      PosterSource="Assets/SplashScreen.png"/>
                    </Grid>
                </Border>
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="Status: "/>
                    <TextBlock x:Name="StatusText" Grid.Column="1"/>
                </Grid>
            </Grid>
        </Grid>

        <!-- Back button and page title -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="BackButton" Margin="39,59,39,0" Command="{Binding NavigationHelper.GoBackCommand, ElementName=PageRoot}"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Top"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="PageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="0,0,30,40"/>
        </Grid>
    </Grid>
</Page>
